package com.example.fairplay.newfpregistration.ui;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.Toast;

import com.example.fairplay.newfpregistration.R;
import com.example.fairplay.newfpregistration.camera.CameraInterface;
import com.example.fairplay.newfpregistration.camera.FacePicInterface;
import com.example.fairplay.newfpregistration.camera.FragmentCamera;
import com.example.mylibrary.MyApp;
import com.example.mylibrary.config.Config;
import com.example.mylibrary.data.ByteImg;
import com.example.mylibrary.data.DBManager;
import com.example.mylibrary.data.Item;
import com.example.mylibrary.data.ItemGrop;
import com.example.mylibrary.data.Sort;
import com.example.mylibrary.data.StudentInfo;
import com.example.mylibrary.data.StudentItem;
import com.example.mylibrary.data.StudentItemGrop;
import com.example.mylibrary.util.ActivityCollector;
import com.example.mylibrary.util.ImageUtil;
import com.example.mylibrary.util.Logger;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;

import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.com.aratek.facelib.AraFaceAuthLib;
import cn.com.aratek.fp.FingerprintScanner;
import cn.com.aratek.idcard.IDCard;
import cn.com.aratek.idcard.IDCardReader;
import cn.com.aratek.util.Result;


public class ItemGropActivity extends AppCompatActivity implements FacePicInterface, AdapterView.OnItemSelectedListener{
    private static final int MAX_VERIFY_COUNT = 5;
    private static final String PATH = Environment
            .getExternalStorageDirectory() + "/sdcard/FP-KTA2203/Photo/";
    private static final int MSG_FP_RESULT = 0;
    private static final int MSG_SHOW_INFO = 1;
    private static final int MSG_CARD_INFO = 2;
    private static final int MSG_SHOW_PROGRESS_DIALOG = 3;
    private static final int MSG_DISMISS_PROGRESS_DIALOG = 4;
    private static final int MSG_FACE_RESULT = 8;
    private boolean isReading = true;
    private IDCardReader mReader;
    private ItemGropActivity.ReadThread mReadThread;
    private IDCard idCard;
    private Bitmap Sbitmap = null;
    private byte[] cardData = null;
    private AraFaceAuthLib araFaceAuthLib;
    private ProgressDialog mProgressDialog;
    private FingerprintScanner mScanner;
    private StudentInfo studentInfo;
    private MyApp app;
    private Logger logger;
    private List<StudentInfo> studentInfos;
    private List<StudentInfo> studentInfoss;
    //android.support.v4.app.Fragment使用  getSupportFragmentManager();
    private FragmentManager manager = getSupportFragmentManager();
    private int FPResult = -99;
    private File fic;
    private File fss;
    private ExecutorService cachedThreadPool;
    private FragmentCamera fragment;
    @Bind(R.id.spinner_sort)
    Spinner spinnerSort;
    @Bind(R.id.spinner_item)
    Spinner spinnerItem;
    @Bind(R.id.spinner_group)
    Spinner spinnerGroup;
    @Bind(R.id.ed_transition)
    EditText ed_transition;
    @Bind(R.id.rl_spinner_view)
    RelativeLayout rlSpinner;

    public static Context mContext;
    private String cardNum;
    private byte[] snapshotFeature;
    private List<StudentInfo> studentInfoAll;
    private ArrayList<ByteImg> bytes;
    private ByteImg byteImg;
    private List<ByteImg> imgList;
    private List<ByteImg> imgList1;
    private String stuCode;
    private RadioGroup radioGroup;
    private ArrayAdapter<String> spinnerSortAdapter;
    private ArrayAdapter<String> spinnerItemAdapter;
    private ArrayAdapter<String> spinnerGroupAdapter;
    private List<Sort> sorts;
    private List<String> spinnerSortArr = new ArrayList<>();
    private List<String>  spinnerItemArr = new ArrayList<>();
    private List<String> spinnerGroupArr = new ArrayList<>();
    private long sortID;
    private long itemID;
    private List<StudentItemGrop> studentItemGrops;
    private List<String> stuCodes;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_item_grop);
        ButterKnife.bind(this);
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        initDatas();
        init();
        mContext =this;
        SharedPreferences settings = getSharedPreferences("preferences_settings",0); //与上面的保持一致
        String name = settings.getString("SelectedSort", "");
        int positionSort = settings.getInt("SelectedSortPosition", 0 );
        spinnerSort.setSelection(positionSort);

    }
    private void init() {
        //下拉列表获取数据
        sorts = new ArrayList<>();
        spinnerSortArr.add("无");
        sorts = DBManager.getInstance(this).sortAll();
        for (Sort sort: sorts){
            spinnerSortArr.add(sort.getSortName());
            Log.e("spinnerSortArr: ",sort.getSortName()+"" );
        }
        //将可选内容与adapter关联  使用默认样式
        spinnerSortAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinnerSortArr);
        //设置下拉分项
        spinnerSortAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        //将adapter添加到spinner中
        spinnerSort.setAdapter(spinnerSortAdapter);
        spinnerSort.setOnItemSelectedListener(this);

    }
    private void initDatas() {
        mProgressDialog = new ProgressDialog(this);
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mProgressDialog.setIcon(android.R.drawable.ic_dialog_info);
        mProgressDialog.setIndeterminate(false);
        mProgressDialog.setCancelable(false);
        mReader = IDCardReader.getInstance(this);
        araFaceAuthLib = MainMenu.getAraFaceAuthLib();
        cachedThreadPool = Executors.newCachedThreadPool();
        mScanner = FingerprintScanner.getInstance(this);
        studentInfo = new StudentInfo();
        app = MyApp.getInstance();
        creatFile();
        //打开设备
    }
    private void creatFile() {
        fic = new File(PATH + "IDCard");
        if (!fic.exists()) {
            try {
                fic.mkdirs();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        fss = new File(PATH + "Snapshot");
        if (!fss.exists()) {
            try {
                fss.mkdirs();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public FragmentCamera getFragment() {
        return fragment;
    }

    @OnClick({R.id.btn_query,R.id.btn_scanner})
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btn_query:

                manualQuery();
                break;
            case R.id.btn_scanner:
                //扫描二维码
                new IntentIntegrator(this)
                        .setOrientationLocked(false)
                        .setCaptureActivity(ScannerActivity.class) // 设置自定义的activity是ScanActivity
                        .initiateScan(); // 初始化扫描

                break;
        }
    }


    //二维码
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        IntentResult intentResult = IntentIntegrator.parseActivityResult(requestCode,resultCode,data);
        if(intentResult != null) {
            if(intentResult.getContents() == null) {
                Toast.makeText(this,"内容为空",Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(this,"扫描成功",Toast.LENGTH_LONG).show();
                // ScanResult 为 获取到的字符串
                String scanResult = intentResult.getContents();
                Intent intent = new Intent(ItemGropActivity.this,MainCheckActivity.class);
                Bundle bundle = new Bundle();
                bundle.putSerializable("scanner",scanResult);
                intent.putExtras(bundle);
                startActivity(intent);
                finish();

                Log.e("Scanner:",scanResult);
            }
        } else {
            super.onActivityResult(requestCode,resultCode,data);
        }
    }
    //打开身份证设备
    private void openDevice() {
        new Thread() {
            @Override
            public void run() {
                int error;
                showProgressDialog(getString(R.string.loading), getString(R.string.preparing_device));
                if ((error = mReader.powerOn()) != IDCardReader.RESULT_OK) {
                    showInfoToast(getString(R.string.id_card_reader_power_on_failed));
                    dismissProgressDialog();
                    return;
                }
                if ((error = mReader.open()) != IDCardReader.RESULT_OK) {
                    showInfoToast(getString(R.string.id_card_reader_open_failed));
                    dismissProgressDialog();
                    return;
                }
                dismissProgressDialog();
                showInfoToast(getString(R.string.device_open_success));
                readCard();
            }
        }.start();
    }

    //显示对话框
    private void showProgressDialog(String title, String message) {
        mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_PROGRESS_DIALOG,
                new String[]{title, message}));
    }

    private void dismissProgressDialog() {
        mHandler.sendMessage(mHandler
                .obtainMessage(MSG_DISMISS_PROGRESS_DIALOG));
    }

    private void readCard() {
        isReading = true;
        if (mReadThread == null) {
            mReadThread = new ItemGropActivity.ReadThread();
            mReadThread.start();
        }
    }

    private void stopReading() {
        isReading = false;
        mReadThread = null;

    }
    //将状态再次 进行判断
    @Override
    protected void onResume() {
        super.onResume();

        if (MyApp.mACache1.getAsString("指纹认证") != null) {
            //开启
            if (Boolean.valueOf(MyApp.mACache1.getAsString("指纹认证"))) {
                //开启状态
                openDevice();
            } else {
                //关闭状态
            }
        }
        if (MyApp.mAcache2.getAsString("是否开启分组") != null) {
            //开启
            if (Boolean.valueOf(MyApp.mAcache2.getAsString("是否开启分组"))) {
                //开启状态
                rlSpinner.setVisibility(View.VISIBLE);


            } else {
                //关闭状态
            }
        }


    }
    //跳转人脸fragment页面
    private void faceResult(){
        bytes=new ArrayList<>();
        byteImg = new ByteImg();
        imgList = new ArrayList<>();

        Log.e("stuCodes: ", stuCodes.size()+"");

            for(int i=0;i<stuCodes.size();i++){
                String str = stuCodes.get(i);
                Log.e("stuCodes1: ", stuCodes.get(i).toString()+"");
                imgList = DBManager.getInstance(this).queryImg(str);
                // imgList = DataDao.imgAll();
                for (int j = 0; j< imgList.size(); j++){
                    ByteImg byteImg=new ByteImg();
                    byteImg = imgList.get(j);
                    if(byteImg.getByteImg() !=null){
                        cardData = byteImg.getByteImg();
                        byteImg.setByteImg(cardData);
                        byteImg.setImgId(imgList.get(j).getImgId());
                        Log.e("imgList: ",imgList.get(j).getStudentCode()+"   "+ cardData);
                        bytes.add(byteImg);
                    }
                }
            }



            fragment = new FragmentCamera();
            //fragment.setBytes(bytes);
            //fragment.setIDCardData(cardData);
            CameraInterface.setVerifyCount(MAX_VERIFY_COUNT);
            FragmentTransaction transaction = manager.beginTransaction();
            transaction.replace(R.id.content2, fragment);
            transaction.addToBackStack(null);
            transaction.commit();




    }
    //返回键按钮操作
    @Override
    public void onBackPressed() {
        super.onBackPressed();
        //startActivity(new Intent(this,MainMenu.class));
        ActivityCollector.removeActivity(this);
        finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        closeDevice();
    }

    //关闭设备
    private void closeDevice() {
        new Thread() {
            @Override
            public void run() {
                int error;
                isReading = false;
                mReadThread = null;
                if ((error = mReader.close()) != IDCardReader.RESULT_OK) {
                    //   showInfoToast(getString(R.string.id_card_reader_close_failed));
                    dismissProgressDialog();
                    return;
                }
                if ((error = mReader.powerOff()) != IDCardReader.RESULT_OK) {
                    //  showInfoToast(getString(R.string.id_card_reader_power_off_failed));
                    dismissProgressDialog();
                    return;
                }

                showInfoToast(getString(R.string.device_close_success));
            }
        }.start();
    }

    private void clearFeature() {
        cardData = null;
        Sbitmap = null;

    }

    private void showInfoToast(String info) {
        mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_INFO, info));
    }

    //读取身份证
    private class ReadThread extends Thread {
        public void run() {
            Result res;
            do {
                res = mReader.read();
            } while (res.error != IDCardReader.RESULT_OK && isReading == true);
            if (res.error == IDCardReader.RESULT_OK) {
                showInfoToast(getString(R.string.id_card_read_success));
                mHandler.sendMessage(mHandler.obtainMessage(MSG_CARD_INFO, (IDCard) res.data));
                idCard = (IDCard) res.data;
                final Result temp = res;
                clearFeature();

                cardNum = idCard.getNumber();
                //将查询到的数据给数组
                stopReading();

            }else {

            }
        }

    }


    //下拉列表
    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

        switch (parent.getId()){
            case R.id.spinner_sort:
                spinnerItemArr.clear();
                SharedPreferences settings ;
                SharedPreferences.Editor editorsettings;
                settings = getSharedPreferences("preferences_settings",Context.MODE_PRIVATE);
                editorsettings = settings.edit();
             String   selectedSort = parent.getItemAtPosition(position).toString();
                Log.e( " selectedName",selectedSort  +position);
                editorsettings.putInt("SelectedSortPosition", position);
                editorsettings.putString("SelectedSort", selectedSort);
                editorsettings.commit();


                Sort sort1 = new Sort();
                Set set = new HashSet();
                List<Item> items = new ArrayList<>();
                String str = (String) spinnerSort.getSelectedItem();
                for (int j =0;j<sorts.size();j++){
                    sort1 = sorts.get(j);
                    if (  sort1.getSortName().equals(str)){
                        sortID = sort1.getSortID();
                        List<ItemGrop> itemGrops =  DBManager.getInstance(this).queryItem(sortID);
                        for (ItemGrop itemGrop: itemGrops){
                            // set.add(String.valueOf(itemGrop.getItemID()));
                            items =   DBManager.getInstance(this).queryItemName(itemGrop.getItemID());
                            for (Item i:items){
                                set.add(i.getItemName());
                            }
                        }
                        spinnerItemArr.add("无");
                        spinnerItemArr.addAll(set);
                        //将可选内容与adapter关联  使用默认样式
                        spinnerItemAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinnerItemArr);
                        //设置下拉分项
                        spinnerItemAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                        //将adapter添加到spinner中
                        spinnerItem.setAdapter(spinnerItemAdapter);
                        spinnerItem.setOnItemSelectedListener(this);

                        SharedPreferences settings1 = getSharedPreferences("preferences_settings1",1);
                        String name1 = settings1.getString("SelectedItem", "");
                        int positionItem = settings1.getInt("SelectedItemPosition", 1 );
                        spinnerItem.setSelection(positionItem);
                    }
                }

                break;
            case R.id.spinner_item:
                spinnerGroupArr.clear();

                SharedPreferences settings1 ;
                SharedPreferences.Editor editorsettings1;
                settings1 = getSharedPreferences("preferences_settings1",Context.MODE_PRIVATE);
                editorsettings1 = settings1.edit();
                String   selectedItem = parent.getItemAtPosition(position).toString();
                Log.e( "selectedItem",selectedItem  +position);
                editorsettings1.putInt("SelectedItemPosition", position);
                editorsettings1.putString("SelectedItem", selectedItem);
                editorsettings1.commit();


                ItemGrop itemGrop = new ItemGrop();
                Set set1 = new HashSet();
                String str1 = (String) spinnerItem.getSelectedItem();
                Log.e( "spinnerItemName",   str1+"");
                if (str1 !=null){
                    List<Item> itemList = DBManager.getInstance(this).queryItemId(str1);
                    for (Item item: itemList){
                        itemID =item.getItemID();
                        Log.e( "onItemSelected: itemId",   item.getItemID()+"");
                        List<ItemGrop> itemGrops =   DBManager.getInstance(this).itemGrop(item.getItemID());
                        for (int i = 0;i<itemGrops.size();i++){
                            itemGrop = itemGrops.get(i);
                            Log.e( "getGropNo ",  itemGrop.getGropNo()+"" );
                            set1.add(itemGrop.getGropNo());
                        }
                    }
                   // spinnerGroupArr.add("无");
                    spinnerGroupArr.addAll(set1);
                    //将可选内容与adapter关联  使用默认样式
                    spinnerGroupAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinnerGroupArr);
                    //设置下拉分项
                    spinnerGroupAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                    //将adapter添加到spinner中
                    spinnerGroup.setAdapter(spinnerGroupAdapter);
                    spinnerGroup.setOnItemSelectedListener(this);
//
//                    SharedPreferences settings2 = getSharedPreferences("preferences_settings2",2);
//                    String name2 = settings2.getString("SelectedGroup", "");
//                    int positionGroup = settings2.getInt("SelectedGroupPosition", 2 );
//                    spinnerGroup.setSelection(positionGroup);

                }else {

                }


                break;
            case R.id.spinner_group:

                SharedPreferences settings2 ;
                SharedPreferences.Editor editorsettings2;
                settings2 = getSharedPreferences("preferences_settings2",Context.MODE_PRIVATE);
                editorsettings2 = settings2.edit();
                String   selectedGroup = parent.getItemAtPosition(position).toString();
                Log.e( " selectedGroup",selectedGroup  +position);
                editorsettings2.putInt("SelectedGroupPosition", position);
                editorsettings2.putString("SelectedGroup", selectedGroup);

                editorsettings2.commit();

                stuCodes = new ArrayList<>();
                int str2 = (int) spinnerGroup.getSelectedItem();
          //查询项目分组id  根据获取到的id查询学生信息
             List<ItemGrop> itemGropList =   DBManager.getInstance(this).queryGropId(sortID,itemID, str2);
                for (ItemGrop itemgrop:itemGropList){
                    Log.e( "itemGropListID: ", itemgrop.getItemGropID()+"");
                    studentItemGrops = DBManager.getInstance(this).queryStudentGrop(itemgrop.getItemGropID());
                    for(StudentItemGrop studentItemGrop:studentItemGrops){
                    List<StudentItem> studentItems =   DBManager.getInstance(this).queryStudentItemID(studentItemGrop.getStudentItemID());
                        for (StudentItem studentItem:studentItems){
                            Log.e( "StudentCode: ", studentItem.getStudentID()+"");
                           List<StudentInfo> stuInfos =  DBManager.getInstance(this).queryStuInfos(studentItem.getStudentID());
                            for(StudentInfo stuinfo:stuInfos){
                                Log.e( "getStudenCode",     stuinfo.getStudenCode()+"");
                                stuCodes.add(stuinfo.getStudenCode());
                            }

                        }
                    }

                }
                if (MyApp.mACache.getAsString("人脸认证") != null) {
                    //开启
                    if (Boolean.valueOf(MyApp.mACache.getAsString("人脸认证"))) {
                        //开启状态
                        faceResult();
                    } else {
                        //关闭状态
                    }
                }

                break;
        }
    }

    @Override
    public void onNothingSelected(AdapterView<?> parent) {

    }

    @Override
    public void fromPic(int requestCode, int resultCode, Intent data) {
        if (requestCode == 222){
            if (resultCode ==1){
                float score = data.getFloatExtra("score",0);
                snapshotFeature = data.getByteArrayExtra("snapshotFeature");
                stuCode = data.getStringExtra("stuCode");
                saveData( snapshotFeature,score, stuCode);
            }else {
                readCard();

            }
        }
    }


    private void saveData(final byte[] snapshotFeature, final float score, final String stuCode) {

        cachedThreadPool.execute(new Runnable() {
            @Override
            public void run() {
                setSnapshotFeature(snapshotFeature,score,stuCode);
            }


        });

    }
    private void setSnapshotFeature(byte[] snapshotFeature, float score,String stuCode) {
        final Bitmap b = ImageUtil.getRotateBitmap(BitmapFactory.decodeByteArray(snapshotFeature,0,snapshotFeature.length), Config.displayOrientation);
        Sbitmap = b;
        String res = String.valueOf(score);
        mHandler.sendMessage(mHandler.obtainMessage(MSG_FACE_RESULT, res));
        ItemGropActivity.this.runOnUiThread(new Runnable() {
            @Override
            public void run() {

            }
        });

    }

    //根据EditText获取值   判断
    public void manualQuery() {

        final String idinfo = ed_transition.getText().toString().trim();
        if (idinfo.isEmpty()){
            Toast.makeText(this, "请输入考号或者身份证", Toast.LENGTH_SHORT).show();
        }
            for(int i=0;i<stuCodes.size();i++){
                String str = stuCodes.get(i);
                Log.e( "manualQuery: stuCodes", str);
                if (idinfo.equals(str)){
                    Intent intent = new Intent(this, MainCheckActivity.class);
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("Idcard", idinfo);
                    intent.putExtras(bundle);
                    startActivity(intent);
                    finish();

                }else{

                 //   Toast.makeText(this, "本组无此人", Toast.LENGTH_SHORT).show();
                }
            }


    }

    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case MSG_SHOW_INFO:
                    Toast.makeText(ItemGropActivity.this, (String) msg.obj,
                            Toast.LENGTH_SHORT).show();
                    break;
                case MSG_CARD_INFO:
                    //获取身份证信息 并跳转
                    IDCard idCard = (IDCard) msg.obj;
                    Intent intent = new Intent(ItemGropActivity.this,MainCheckActivity.class);
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("idcardinfo",idCard.getNumber());
                    byte[] fpbytes =  idCard.getFingerprint();
                    //将指纹信息传出
                    bundle.putSerializable("fpinfo",fpbytes);
                    intent.putExtras(bundle);
                    startActivity(intent);
                    finish();
                    break;
                case MSG_SHOW_PROGRESS_DIALOG: {
                    String[] info = (String[]) msg.obj;
                    mProgressDialog.setTitle(info[0]);
                    mProgressDialog.setMessage(info[1]);
                    mProgressDialog.show();
                    break;
                }
                case MSG_DISMISS_PROGRESS_DIALOG: {
                    mProgressDialog.dismiss();
                    break;
                }
                case  MSG_FACE_RESULT:{
                    //人脸比对 结果
                    String res = (String) msg.obj;
                    float score = Float.valueOf(res);
                    if(score == -1){
                        Toast.makeText(ItemGropActivity.this, "比对失败", Toast.LENGTH_SHORT).show();
                    }else if(score == 0){
                        Toast.makeText(ItemGropActivity.this, "比对失败", Toast.LENGTH_SHORT).show();
                    }else {
                        Toast.makeText(ItemGropActivity.this, "比对成功", Toast.LENGTH_SHORT).show();
                        Intent faceIntent = new Intent(ItemGropActivity.this,MainCheckActivity.class);
                        //将身份证号传递出去
                        //不能传BItmap对象  只能转成字节进行传递 否则跳转不成功
                        faceIntent.putExtra("snapshotFeature",snapshotFeature);
                        faceIntent.putExtra("stuCode",stuCode);
                        startActivity(faceIntent);

                    }
                    break;
                }


            }


        }

    };

}
